<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ContactPage.aspx.cs" Inherits="ContactPage" %>

<%@ Register Src="Controls/GridControl.ascx" TagName="GridControl" TagPrefix="edn" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
	<title>Contact List</title>
</head>

<script type="text/javascript">

function OnRowDblClicked()
{
    var oItems = document.crmGrid.getSelectedItems();
    if (IsNull(oItems) || oItems.length == 0) {
        return;
    }
    alert(oItems[0].itemlabel + " DblClicked");
}

function OnMenuItemClicked()
{
	alert("Not implemented...");
	event.returnValue = false;
}


function OnCrmGridToggleExpand(oGridContrl, colindex, expand)
{
    if (colindex == 1) {
        return false;//icon column should not toggle expand
    }
    return true;
}

function OnRowSelectionChanged(oGridContrl, itemindex, selected)
{
    if (itemindex == -1) {
        alert("Select All Clicked");
        return;
    }
    var oItem = oGridContrl.getItem(itemindex);
    alert(oItem.itemlabel + (selected ? " Selected" : " Deselected"));
    return true;
}

</script>

<body>
	<form id="form1" runat="server" >
	<asp:ScriptManager ID="ScriptManager1" runat="server">
	</asp:ScriptManager>
		<table class="layoutTable" cellpadding="0" cellspacing="0">
			<tr height="25">
			    <td class="mscrm-MenuBar">
                	<asp:Menu ID="Menu1" runat="server" DisappearAfter="-1" >
					    <Items>
							<asp:MenuItem Text="<span class='dropButton'><img src='Images/ico_16_2_d.gif' class='menuImage'/>New</span>" ImageUrl="" SeparatorImageUrl="~/Images/toolbar_separator.gif" Selectable="false">
								<asp:MenuItem Text="<span onclick='OnMenuItemClicked()'>New</span>"></asp:MenuItem>
								<asp:MenuItem Text="<span onclick='OnMenuItemClicked()'>Add Existing</span>"></asp:MenuItem>							
							</asp:MenuItem>
							<asp:MenuItem Text="<span class='toolButton'><img src='Images/16_send.gif' class='menuImage' onclick='OnMenuItemClicked()'/></span>"></asp:MenuItem>
							<asp:MenuItem Text="<span class='toolButton'><img src='Images/ico_mailmerge.gif' class='menuImage' onclick='OnMenuItemClicked()'/></span>" SeparatorImageUrl="~/Images/toolbar_separator.gif"></asp:MenuItem>
							<asp:MenuItem Text="<span class='toolButton'><img src='Images/16_reports.gif' class='menuImage' onclick='OnMenuItemClicked()'/></span>"></asp:MenuItem>
							<asp:MenuItem Text="<span class='toolButton'><img src='Images/ico_16_merge.gif' class='menuImage' onclick='OnMenuItemClicked()'/></span>" SeparatorImageUrl="~/Images/toolbar_separator.gif">
							</asp:MenuItem>
							<asp:MenuItem Text="<span class='dropButton'><img src='Images/ico_16_minicamp.gif' class='menuImage' onclick='OnMenuItemClicked()'/>Create Quick Campaign</span>" Selectable="false" SeparatorImageUrl="~/Images/toolbar_separator.gif">
								<asp:MenuItem Text="<span onclick='OnMenuItemClicked()'>For Selected Records</span>"></asp:MenuItem>
								<asp:MenuItem Text="<span onclick='OnMenuItemClicked()'>For All records</span>"></asp:MenuItem>
							</asp:MenuItem>
							<asp:MenuItem Selectable="false" Text="<span class='dropMenu'>More Actions</span>">
								<asp:MenuItem Text="<span onclick='OnMenuItemClicked()'>No More Actions</span>"></asp:MenuItem>
							</asp:MenuItem>
						</Items>
					</asp:Menu>
				</td>
            </tr>
			<tr>
				<td>
					<asp:UpdatePanel ID="upGridArea" runat="server">
					<ContentTemplate>
						<edn:GridControl ID="crmGrid" runat="server" EnableViewState="false" AllowClientSideSelection="true" AutoGenerateColumns="false" DisplayStatusBar="true" OnQueryDataSource="crmGrid_QueryDataSource" OnClientRowDblClick="OnRowDblClicked" OnToggleExpand="OnCrmGridToggleExpand" OnClientRowSelectionChanged="OnRowSelectionChanged" DataLabelField="fullname">
							<Columns>
								<asp:TemplateColumn HeaderStyle-Width="32px" ItemStyle-Width="32px">
									<ItemTemplate>
										<img src="Images/ico_16_2_d.gif" align="left"/>&nbsp
									</ItemTemplate>
								</asp:TemplateColumn>
								<asp:BoundColumn DataField="fullname" HeaderText="Name" SortExpression="fullname" HeaderStyle-Width="120px" ItemStyle-Width="120px"/>
								<asp:BoundColumn DataField="emailaddress1" HeaderText="Email" SortExpression="emailaddress1" HeaderStyle-Width="120px" ItemStyle-Width="120px"/>
								<asp:BoundColumn DataField="telephone1" HeaderText="Business Phone" SortExpression="telephone1" HeaderStyle-Width="120px" ItemStyle-Width="120px"/>
							</Columns>
						</edn:GridControl>					
					</ContentTemplate>
					</asp:UpdatePanel>
				</td>
			</tr>
		</table>
	</form>
</body>
</html>
